<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<jsp:include page="/WEB-INF/jspf/header.jsp">
    <jsp:param name="title" value="View Transactions" />
</jsp:include>

<f:view>
    <h:form>
        <h:outputText rendered="#{bankTransaction.initAccountDetails}" />
        <%@include file="/WEB-INF/jspf/menu_customer.jspf" %>

        <h:inputHidden binding="#{bankTransaction.inputHidden}" value="#{bankTransaction.accountId}"  />

        <h1><h:outputText value="Transactions" /></h1>
        <h3> <h:outputText value="Account Id: #{bankTransaction.accountId}" /></h3>
        <h3> <h:outputText value="Account balance: #{bankTransaction.balance}" /></h3>

        <h:commandButton value="Send Statement" action="#{bankTransaction.send}">
        </h:commandButton>
        <h:outputLink value="transferMoney.jsp">
            <f:param name="accountId" value="#{bankTransaction.inputHidden.value}"/>
            <h:outputText value="Transfer Money"/>
        </h:outputLink>

        <h:dataTable value="#{bankTransaction.accountTransactions}" var="item" rowClasses="evenRow, oddRow" border="2" cellspacing="5" cellpadding="5" >
            <h:column>
                <f:facet name="header" >
                    <h:outputText value="Transfer"  />
                </f:facet>
                <h:outputLink value="transferMoney.jsp" rendered="#{item.render}"><center>
                    <img src="../../repeat_prevod.gif" width="14" height="14" alt="repeat_prevod"/></center>
                    <f:param  name="accountId" value="#{bankTransaction.accountId}"/>
                    <f:param  name="to" value="#{item.to.id}"/>
                    <f:param  name="amount" value="#{item.customerAmount}">
                    </f:param>
                </h:outputLink>
            </h:column>


            <h:column>
                <f:facet name="header">
                    <h:outputText value="Amount"/>
                </f:facet>
                <h:outputText value=" #{item.customerAmount}" styleClass="#{item.styleClass}">
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Counter-account"/>
                </f:facet>
                <h:outputText value="#{item.contraAccount}"/>
            </h:column>

            <h:column>
                <f:facet name="header">
                    <h:outputText value="TransferDate"/>
                </f:facet>
                <h:outputText value=" #{item.transferDate}"/>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="TransferTime"/>
                </f:facet>
                <h:outputText value=" #{item.transferTime}"/>
            </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Id"/>
                </f:facet>
                <h:outputText value=" #{item.id}" />
            </h:column>
        </h:dataTable>
    </h:form>
    </body>
    </html>
</f:view>
